// api/routes/simple_routes.go
package routes

import (
	"mygin/api/handlers"
	"mygin/internal/repositories"
	"mygin/internal/services"

	"github.com/gin-gonic/gin"
	"gorm.io/gorm"
)

// func RegisterTestRoutes(r *gin.RouterGroup) {
// 	// 直接创建handler，不需要db或service
// 	testHandler := handlers.NewTestHandler(nil)
// 	testRoutes := r.Group("/tests")
// 	{
// 		// CRUD路由
// 		testRoutes.POST("", testHandler.CreateTest)
// 		testRoutes.GET("", testHandler.ListTests)
// 		testRoutes.GET("/:id", testHandler.GetTest)
// 		testRoutes.PUT("/:id", testHandler.UpdateTest)
// 		testRoutes.DELETE("/:id", testHandler.DeleteTest)
// 		// 其他简单路由...
// 	}
// }

func RegisterTestRoutes(r *gin.RouterGroup, db *gorm.DB) {
	tserRepo := repositories.NewTestRepository(db)
	tserService := services.NewTestService(tserRepo)
	testHandler := handlers.NewTestHandler(tserService)
	// 直接创建handler，不需要db或service
	testRoutes := r.Group("/tests")
	{
		// CRUD路由
		testRoutes.POST("", testHandler.CreateTest)
		testRoutes.GET("", testHandler.ListTests)
		testRoutes.GET("/:id", testHandler.GetTest)
		testRoutes.PUT("/:id", testHandler.UpdateTest)
		testRoutes.DELETE("/:id", testHandler.DeleteTest)
		// 其他简单路由...
	}
}
